<?php
/**
 * 获取文件夹下所有文件
 * @package package.file
 * @access public
 * @param $file 文件
 * @author alex(gt199899@gmail.com)
 * @version 2014-01-23
 * @copyright Perfect Is Shit(FROM THINKPHP)
 */
function getDirFiles($dir){
	$fileArray[] = NULL;
	if(false != ($handle = opendir($dir))){
		$i=0;
		while ( false !== ($file = readdir ( $handle )) ) {
			if ($file != "." && $file != ".." && strpos($file,".")) {
				$fileArray[$i] = $file;
				$i++;
			}
		}
		closedir ( $handle );
	}
	return $fileArray;
}

/**
 * 根据数组一个键排序
 * @param $arr 待排序数组
 * @param $keys 要排序的键
 * @param $type asc正序,desc逆序
 * @return $new_array 排序完成的数组
 * @author www
 * @modify alex 20140716 增加参数，是否重置数组键
 * @version 20131113
 */
function arraySort($arr,$keys,$type='asc', $reset = false){
    $keysvalue = $new_array = array();
    foreach ($arr as $k=>$v){
        $keysvalue[$k] = $v[$keys];
    }
    if($type == 'asc'){
        asort($keysvalue);
    }else{
        arsort($keysvalue);
    }
    reset($keysvalue);
	if($reset == true){
		$i = 0;
	}
    foreach ($keysvalue as $k=>$v){
		if($reset == true){
			$new_array[$i] = $arr[$k];
			$i++;
		}
		else{
			$new_array[$k] = $arr[$k];
		}
    }
    return $new_array;
}